<template>
    <div>
        <div class="detail-header">
            <van-nav-bar title="修改任务" left-text="返回" right-text="" left-arrow @click-left="onClickLeft"/>
        </div>
        <div class="updatatask">
            <optitem @todetail="onupdataTask(updatalist[index])" v-for="(item,index) in updatalist" :key="item._id"
                :titlename="item.title" :price="item.price" :label="item.select" />
        </div>
    </div>
</template>
<script>
import optitem from '@/components/item.vue'
import { reqTask } from '@/axios/index.js'
import { mapState } from 'vuex';
export default {
    components: {
        optitem
    },
    data() {
        return {
            updatalist: []
        }
    },
    computed: {
        ...mapState([
            'user',
        ])
    },
    methods: {
        onClickLeft() {
            this.$router.push('/home/publish')
        },
        onupdataTask(item) {
            console.log(item);
            this.$router.push({ name: 'newTask', query: item })
        },
        onClickRight(){

        }
    },
    mounted() {
        reqTask({
            userId: this.user.userId
        }).then((res) => {
            console.log(res);
            this.updatalist = res.data.reqTask
        })
    }
}
</script>
<style lang="less" scoped>
.updatatask {
    padding: 10px 15px;
    background: rgb(243, 241, 222);
}
</style>